#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    string s = "";
    vector <string> v;
    string vs = "";
    getline(cin, s);
    int k = 0;
    int k2 = 0;
    int k3 = 0;
    int k4 = 0;
    int k5 = 0;
    int k6 = 0;
    int c = 4;
    int e = 0;
    int d = 0;
    string mas[3];
    int nomer[3];

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == ' ') {
            v.push_back(vs);
            vs = "";
        }
        else if (s[i] != ' ') {
            vs = vs + s[i];
        }
    }
    v.push_back(vs);

    for (int i = 0; i < v.size(); i++) {
        mas[i] = v[i];
    }
    for (int i = 0; i < v.size(); i++) {
        if(mas[i] == "one" || mas[i] == "two" || mas[i] == "three" || mas[i] == "four" || mas[i] == "five" || mas[i] == "six" || mas[i] == "seven" || mas[i] == "eight" || mas[i] == "nine" || mas[i] == "zero"){
          k = k + 1;  
        }
        else if(mas[i] == " "){
            k6 = k6 + 1;
        }
    }
    if(k != 3 || k6 == 2){
        cout<<"Wrong input";
    }else{
      for (int i = 0; i < k; i++){
        if(mas[i] == "one" )
            {
            nomer[i] = 1;    
            }
        else if(mas[i] == "two")
            {
            nomer[i] = 2;    
            }
        else if(mas[i] == "three")
            {
            nomer[i] = 3;    
            }
        else if(mas[i] == "four" )
            {
            nomer[i] = 4;    
            }
        else if(mas[i] == "five")
            {
            nomer[i] = 5;    
            }
        else if(mas[i] == "six")
            {
            nomer[i] = 6;    
            }
        else if(mas[i] == "seven")
            {
            nomer[i] = 7;    
            }
        else if(mas[i] == "eight")
            {
            nomer[i] = 8;    
            }
        else if(mas[i] == "nine")
           {
            nomer[i] = 9;   
           }
        else if(mas[i] == "zero")
           {
            nomer[i] = 0;   
           }

      } 
      for (int i = 0; i < 3; i++){
          if(i == 0){
              e = e + nomer[i] * 100;
          }
          if(i == 1){
                e = e + nomer[i] * 10;
            }
          if(i == 2){
                e = e + nomer[i];
            }
      }
        d = e;
        while (c > 1){
            k4 = 0;
            for (int i = 1; i < d + 1; i++){
                if (d % i == 0){
                    k4 = k4 + 1;
                        }
            }
            if (k4 == 2){        
                k5 = k5 + 1;
                break;
                    }
            else{
                d = d + 1;
                k5 = k5 + 1;
                    }
                }
            while (c > 1){
                k2 = 0;
                for (int i = 1; i < e + 1; i++){
                    if (e % i == 0){
                        k2 = k2 + 1;
                            }
                }
                if (k2 == 2){        
                    k3 = k3 + 1;
                    break;
                        }
                else{
                    e = e - 1;
                    k3 = k3 + 1;
                        }
                    }
        if (k3 < k5){
            cout<<e;
        }   
        if (k5 < k3){
            cout<<d;
            }
      if  (k5 == k3){
            if (d < e){
                cout<<d;
            }
            else{
                cout<<e;
            }
            }
    }
        }